<?php
	function logoutUser($username)
	{
		setcookie('username',$username,time()*60*24);
		if(isset($_SESSION['username']))
		{
			unset($_SESSION['username']);
		}
		if(isset($_SESSION['password']))
		{
			unset($_SESSION['password']);
		}
		if(isset($_SESSION['lastActiveTime']))
		{
			unset($_SESSION['lastActiveTime']);
		}
		return true;
	}
	
	function isTimedOut()
	{
		if(isset($_SESSION['lastActiveTime']))
		{
			$idleTime = time() - $_SESSION['lastActiveTime'] ;
			
			if(($idleTime/60)>5)
			{	
				return true;
			}
			else
			{
				$_SESSION['lastActiveTime'] = time();
				return false;
			}
		}
		else
		{
			return true;
		}
	}
	function timeoutUser()
	{
		if(isset($_SESSION['lastActiveTime']))
		{
			$idleTime = time() - $_SESSION['lastActiveTime'] ;
			
			if(($idleTime/60)>5)
			{	
				$this->logoutUser();
				return true;
			}
			else
			{
				$_SESSION['lastActiveTime'] = time();
				return false;
			}
		}
		else
		{
			return true;
		}
	}
?>